//
//  WelcomeVC.m
//  BuyHomeTeamPro
//
//  Created by wy on 16/11/11.
//  Copyright © 2016年 wy. All rights reserved.
//

#import "WelcomeVC.h"

#import "CJRootVCSelectionTool.h"
@interface WelcomeVC ()<UIScrollViewDelegate>
@property (nonatomic, strong)UIScrollView *scrollerView;

@property (nonatomic, assign)CGSize currentSize;

@end

@implementation WelcomeVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setStarWelcome];
}
-(void)setStarWelcome{
//    NSArray *imageArr = @[@"1.jpg",@"2.jpg",@"3.jpg"];
    NSArray *imageArr = @[@"轮播2",@"轮播5"];
    int pageNum = (int)imageArr.count;
    _currentSize = [UIScreen mainScreen].bounds.size;
    _scrollerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    _scrollerView.contentSize = CGSizeMake(imageArr.count *_currentSize.width, _currentSize.height);
    [self.view addSubview:_scrollerView];
    for (int i =0; i< imageArr.count; i++) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*_currentSize.width, 0, _currentSize.width, _currentSize.height)];
        imageView.tag = i;
        if (imageView.tag == pageNum-1) {
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            [btn setTitle:@"开始体验" forState:UIControlStateNormal];
            btn.backgroundColor = kCommonRedColor;
            [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
            btn.bounds = CGRectMake(0, 0, 110, 38);
            btn.center = CGPointMake(_currentSize.width/2, _currentSize.height - 80);

            btn.layer.cornerRadius = 6;
            btn.layer.shadowOffset =  CGSizeMake(1, 2);
            btn.layer.shadowOpacity = 0.8;
            btn.layer.shadowColor =  [UIColor blackColor].CGColor;
            [btn addTarget:self action:@selector(welcomeNewBtn) forControlEvents:UIControlEventTouchUpInside];
            imageView.userInteractionEnabled = YES;
            [imageView addSubview:btn];
        }
        imageView.image = [UIImage imageNamed:imageArr[i]];
        [_scrollerView addSubview:imageView];
    }
    _scrollerView.pagingEnabled = YES;
    _scrollerView.bounces = NO;
    _scrollerView.delegate =self;
    _scrollerView.showsVerticalScrollIndicator = NO;
    _scrollerView.showsHorizontalScrollIndicator = NO;

    //    [self.view bringSubviewToFront:_pageControl];
}

-(void)welcomeNewBtn{
    // 根据授权与否选择窗口根控制器
    [CJRootVCSelectionTool setRootViewControllerForWindow:[UIApplication sharedApplication].keyWindow];

   

}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
